Skip to content

Conversation

@iamgabrielma
Copy link
Contributor

@iamgabrielma iamgabrielma commented Jul 30, 2025

This is the iOS counterpart of woocommerce/woocommerce-android#14134

Description

This PR fixes order creation rounding issues by adding the dp=8 (decimal places) parameter in create and update order API requests, which by default is set to 2 if nothing is passed in.

This increases decimal precision to reduce discrepancies between client-side calculations and backend totals, addressing cases where item totals were incorrectly rounded (e.g., $6 product with 9% tax showing $11.00 instead of $11.01 for quantity of 2).

Changes

  • Updated decimal points from 2 to 8
  • Updated a variable name, just for clarity.
  • Added regression tests

Steps to reproduce/Testing information

In general I found the tax setup and results quite confusing when sending from one country to another, the easier setup seemed to be to set your store to country X, and sells to a customer of the same country. Here's some conversation with some troubles we found during the debugging process in case you find something off with the tax calculation: p1753783743005429-slack-CGPNUU63E

  • Add a product with price that results in non-terminating decimal after tax calculation (e.g., $6 with 9% tax = $5.504587 pre-tax) (Make sure the Enter product prices including tax settings is enabled)
  • Increase quantity to 2 or more in cart
  • Observe total calculation discrepancy between displayed rounded values and actual precise calculations
  • Complete order creation and verify totals match between app and WooCommerce backend

Screenshots

Before After
IMG_1844 IMG_1846
Screenshot 2025-07-30 at 10 20 49
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@iamgabrielma iamgabrielma added this to the 23.0 milestone Jul 30, 2025
@iamgabrielma iamgabrielma added feature: order details Related to order details. feature: order creation All tasks related to creating an order Bug labels Jul 30, 2025
@iamgabrielma iamgabrielma marked this pull request as ready for review July 30, 2025 03:29
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jul 30, 2025

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr15957-1c5234a
Version22.9
Bundle IDcom.automattic.alpha.woocommerce
Commit1c5234a
Installation URL6vg9bt0c5kq7g
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@iamgabrielma iamgabrielma requested a review from staskus July 30, 2025 07:04
@staskus
Copy link
Contributor

staskus commented Jul 30, 2025

@iamgabrielma excuse me for not reaching it today, I will review it tomorrow.

Copy link
Contributor

@staskus staskus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, great work and investigation. Taxes are always a challenging area.

I didn't know we can send more decimal points to the API. I was always frustrated with some of the imprecision that would happen with a combination of tax rates and product prices. This does look to improve it 👍

@iamgabrielma iamgabrielma enabled auto-merge August 1, 2025 02:22
@iamgabrielma iamgabrielma merged commit bdbc520 into trunk Aug 1, 2025
13 checks passed
@iamgabrielma iamgabrielma deleted the task/WOOMOB-556-mitigate-tax-rounding branch August 1, 2025 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug feature: order creation All tasks related to creating an order feature: order details Related to order details.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants